//
//  ToBeSureCheckItemCell.m
//  MyProject
//
//  Created by Pei on 16/7/14.
//  Copyright © 2016年 Xiaobo Pei. All rights reserved.
//

#import "ToBeSureCheckItemCell.h"

@implementation ToBeSureCheckItemCell

{
    UILabel *_headerLbl;
    UILabel *_dateLbl;
    
    UILabel *_titleLbl;
    UILabel *_detailLbl;
    
    UILabel *_statusLbl;
    
    UIImageView *_arrowImageView;
    UIView *_centerLineView;
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = kWhiteColor;
        
        _headerLbl = [[UILabel alloc] init];
        _headerLbl.frame = CGRectMake(10.0f, (80.0f-55.0f)/2.0f, 0.0f, 55.0f);
        _headerLbl.layer.masksToBounds = YES;
        _headerLbl.layer.cornerRadius = 55.0f/2.0f;
        _headerLbl.backgroundColor = [UIColor grayColor];
        _headerLbl.text = @"用电";
        _headerLbl.textColor = kWhiteColor;
        _headerLbl.textAlignment = NSTextAlignmentCenter;
        _headerLbl.font = kAppFont(Home_Big_Size+4.0f);
        [self addSubview:_headerLbl];
        
        _dateLbl = [[UILabel alloc] init];
        _dateLbl.frame = CGRectMake(kDeviceWidth-10.0f-70.0f, _headerLbl.origin.y, 70.0f, Home_Small_Size);
        _dateLbl.text = @"2016-06-23";
        _dateLbl.textColor = kRedColor;
        _dateLbl.textAlignment = NSTextAlignmentRight;
        _dateLbl.font = kAppFont(Home_Small_Size);
        _dateLbl.textColor = kRGB(205, 206, 207);
        [self addSubview:_dateLbl];
        
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.frame = CGRectMake(_headerLbl.right+10.0f, _headerLbl.origin.y, kDeviceWidth-10.0f-10.0f*2.0f-_headerLbl.width-_dateLbl.width, Home_Small_Size+2.0f);
        _titleLbl.text = @"检查任务-专项检查0001";
        _titleLbl.font = kAppFont(Home_Small_Size+2.0f);
        _titleLbl.textColor = kBlackColor;//kRGB(167, 168, 168);
        [self addSubview:_titleLbl];
        
        _detailLbl = [[UILabel alloc] init];
        _detailLbl.frame = CGRectMake(_titleLbl.origin.x, _titleLbl.bottom+5.0f, kDeviceWidth-10.0f-10.0f*2.0f-_headerLbl.width, Home_Small_Size);
        _detailLbl.text = @"公司-工区   机械";
        _detailLbl.font = kAppFont(Home_Small_Size);
        _detailLbl.textColor = kBlackColor;//kRGB(167, 168, 168);
        [self addSubview:_detailLbl];
        
        _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"06jiantou-"]];
        _arrowImageView.frame = CGRectMake(kDeviceWidth-10.0f/2.0f-10.0f,_detailLbl.origin.y+(Home_Small_Size-(19.0f/2.0f))/2.0f, 10.0f/2.0f, 19.0f/2.0f);
        [self addSubview:_arrowImageView];
        
        _centerLineView = [[UIView alloc] initWithFrame:CGRectMake(_titleLbl.origin.x, _detailLbl.bottom+5.0f, kDeviceWidth-10.0f-10.0f*2.0f-_headerLbl.width, 0.5f)];
        _centerLineView.backgroundColor = kGreenColor;
        [self addSubview:_centerLineView];
        
        _statusLbl = [[UILabel alloc] init];
        _statusLbl.frame = CGRectMake(_titleLbl.origin.x, _centerLineView.bottom+8.0f, 200.0f, Home_Small_Size);
        _statusLbl.text = @"专项检查";
        _statusLbl.font = kAppFont(Home_Small_Size);
        _statusLbl.textColor = kRGB(205, 206, 207);
        [self addSubview:_statusLbl];
        
        
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 80.0f-0.5f, kDeviceWidth-10*2, 0.5f)];
        lineView.backgroundColor = kGreenColor;
        [self addSubview:lineView];
    }
    
    return self;
}



- (void)showWithData:(NSDictionary*)data
{
    _titleLbl.text = [data valueForKey:@"InspectItemName"];//InspectItemName
    _dateLbl.text = [NSString stringWithFormat:@"扣分:%d", [[data valueForKey:@"RiskPoints"] intValue]];
    _dateLbl.textColor = [UIColor redColor];
    NSArray *arrayT = [[NSUserDefaults standardUserDefaults] objectForKey:select_RiskLevel];
    for (NSDictionary *yyy in arrayT) {
        if ([[yyy valueForKey:@"Value"] intValue] == [[data valueForKey:@"RiskLevel"] intValue]) {
            _detailLbl.text = [yyy valueForKey:@"Name"];
        }
    }
    //_detailLbl.text = [NSString stringWithFormat:@"%d", [[data valueForKey:@"RiskLevel"] intValue]];
    _statusLbl.text = [NSString stringWithFormat:@"%@", [data valueForKey:@"RiskDesc"]];
}

@end
